<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>{{ settings.title|default("ME@deepgully") }}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="ME@deepgully">
    <meta name="author" content="deepgully">
    {% block header %}
    {% endblock %}

    {% set mirror_site = "" if admin_page else settings.MirrorSite %}
    <!-- CSS styles -->
    {% set theme = (settings.theme or "default").lower() %}
    <link href="{{ mirror_site }}/static/themes/{{ theme }}/bootstrap.min.css" rel="stylesheet"/>
    <link href="{{ mirror_site }}/static/assets/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"/>

    <link href="{{ mirror_site }}/static/assets/bootstrap/lightbox/ekko-lightbox.css" rel="stylesheet"/>
    <link href="{{ mirror_site }}/static/assets/bootstrap/lightbox/dark.css" rel="stylesheet"/>

    <link href="{{ mirror_site }}/static/themes/base.css" rel="stylesheet"/>
    {% set theme_css = theme_file(theme, "styles.css") %}
    {% if theme_css %}
    <link href="{{ mirror_site }}{{ theme_css }}" rel="stylesheet"/>
    {% endif %}
    {% block css %}
    {% endblock %}

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.min.js"></script>
      <script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
    <![endif]-->

    {% if settings.ga_tracking_id %}
    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', '{{ settings.ga_tracking_id }}']);
        _gaq.push(['_trackPageview']);

        (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>
    {% endif %}
<!-- Script -->
<script src="//ajax.useso.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>window.jQuery || document.write(unescape('%3Cscript src="{{ mirror_site }}/static/assets/jquery/jquery-1.11.1.min.js"%3E%3C/script%3E'))</script>
<script src="//libs.useso.com/js/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script>$.fn.carousel || document.write(unescape('%3Cscript src="{{ mirror_site }}/static/assets/bootstrap/bootstrap-3.1.1.min.js"%3E%3C/script%3E'))</script>

<script src="{{ mirror_site }}/static/assets/bootstrap/lightbox/ekko-lightbox.js"></script>

<script src="{{ mirror_site }}/static/js/main.js"></script>

{#% set theme_js = theme_file(theme, "script.js") %#}
{#% if theme_js %#}
{# <script src="{{ mirror_site }}{{ theme_js }}"></script> #}
{#% endif %#}

<script type="text/javascript">
/* Document Ready */
$(document).ready(function() {
    $("#tags_cloud_btn").popover({
        "html": true,
        "placement": "bottom",
        "content": function(){
            return $("#tags_cloud").html();
        }
    });

    $.json_action("tags/hot",{},
        function(resp){
            var tags_cloud = $("#tags_cloud>.tags_cloud");
            tags_cloud.empty();
            $.each(resp.tags, function(index, tag){
                tags_cloud.append('<a class="tag btn btn-default btn-sm" href="/tags/{0}">{0}({1})</a>'.format(tag.name, tag.post_count));
            });
        },function(err){
            bootbox.alert(err);
    });

    // delegate calls to data-toggle="lightbox"
    $(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
        event.preventDefault();
        return $(this).ekkoLightbox({
            left_arrow_class: '.fa .fa-chevron-left .glyphicon-chevron-left',
            right_arrow_class: '.fa .fa-chevron-right .glyphicon-chevron-right'
        });
    });
});
</script>
{% block script %}
{% endblock %}
</head>

<body>
<!-- Nav Bar -->
<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
  <div class="container">
    <div class="navbar-header ">
      <a  class="navbar-brand" href="/" >
        {{ settings.title|default("ME@deepgully")|safe }}
        <i><small> {{ settings.subtitle }} </small></i>
      </a>
      <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <div class="navbar-collapse collapse navbar-inverse-collapse" id="navbar-main">
      <ul class="nav navbar-nav">
        {% for _category in settings.categories %}
          {% if not _category.hidden %}
          <li class="{% if category and category.url == _category.url %}active{% endif %}">
            <a href="/{{ _category.url }}">{{ _category.name }}</a>
          </li>
          {% endif %}
        {% endfor %}
        <li class="{% if tag %}active{% endif %}">
            <a href="javascript:;" id="tags_cloud_btn">
                <i class="fa fa-tags"></i> {{ _("Tags") }}
                <span class="caret"></span>
            </a>
        </li>
      </ul>

      <ul class="nav navbar-nav navbar-right">
      {% if user.is_admin() %}
      {% if category %}
      <li>
        <a id="new-post" href="javascript:;"><i class="fa fa-edit"></i> {{ _("New Post") }}</a>
      </li>
      {% endif %}
      {% endif %}

      {% if user.is_user() %}
        <li class="dropdown {% if not category and not tag %}active{% endif %}">
            <a class="dropdown-toggle"
               data-toggle="dropdown" href="#" id="user">
                <img src="{{ user.avatar_url }}" class="avatar24"/>
                <span>{{ user.nickname }}</span>
                <span class="caret"></span>
            </a>
            <ul class="dropdown-menu" aria-labelledby="user">
                {% if user.is_admin() %}
                <li> <a href="/admin"><i class="fa fa-wrench"></i> {{ _("Admin") }}</a> </li>
                {% endif %}
                <li> <a href="/admin"><i class="fa fa-user"></i> {{ _("Personal") }}</a> </li>
                <li><a href="/logout"><i class="fa fa-sign-out"></i> {{ _("Logout") }}</a></li>
            </ul>
        </li>
      {% else %}
        <li>
           <a href="/login"><i class="fa fa-user"></i> {{ _("Login") }}</a>
        </li>
      {% endif %}
        <li>
          <a href="/feed"><i class="fa fa-rss"></i> {{ _("RSS") }}</a>
        </li>
      </ul>
    </div>
  </div>
</div>

<div class="container">
{% block body %}
{% endblock %}
</div>
<!-- Footer -->
<div class="container">
    <footer>
    <div class="row">
      <div class="col-lg-12">
        <hr/>
        <p><i class="icon-heart"></i>
            <span class=""> {{ settings.title|safe }} {{ settings.copyright|safe }}.</span>
            {{ _("Powered by") }}<a href="http://github.com/deepgully/me/"><code>ME@deepgully v{{ settings.version }}.{{ config['APP_VER'] }}</code></a>
        </p>
      </div>
    </div>
    </footer>
</div>
<!-- Tags -->
<div id="tags_cloud" class="dis-none">
    <div class="tags_cloud">
        <img class="loading" src="{{ mirror_site }}/static/images/posts_loading.gif" alt="{{ _("loading") }}..."/>
    </div>
</div>
</body>
</html>
